When creating an image for display on a computer screen or other display, it is often desirable to use a "texture" (sometimes referred to as a "pattern" or "wallpaper"). For instance, shapes created in a drawing program on a personal computer or workstation may be filled with textures that depict bricks, waves, scales, or other images. Likewise, many personal computers display a textured desktop as the default background screen.
To reduce the storage space required when using textures, and to make the application of textures to objects faster, textures may be "tiled." Tiling includes taking a defined texture region (known as a "tile") such as a textured rectangle, and stamping out repeated adjacent copies of the tile to cover a surface region. Tiling is preferably "seamless" in that the borders between tiles are difficult or impossible to see. Copies of a tile can be placed on a computer display very rapidly, and a single copy of a tile often fits in a small piece of computer memory.
Textures come in many varieties, including without limitation visual textures, bump maps, and masks. Visual textures contain pixel values which are displayed directly on a screen. Screen backgrounds and fill patterns in drawing programs are some of the many examples of visual textures.
Bump maps help distort the smooth surface of an object with apparent bumps or ripples. Bump maps may be used to efficiently produce a surface that appears three-dimensional but is actually modeled internally in a simpler two-dimensional form. One type of bump map produces a pebbly surface, another type gives a cloth-like appearance, and there are many others as well.
A mask is a region with "holes" that specify which pixels will be drawn and which will be suppressed or altered. A mask may be used when drawing one object behind another object, so the apparently closer object hides the apparently distant one. A mask can also be used to composite an image of a meteorologist over an image of a weather map to make it appear as though the meteorologist is standing in front of a large weather map when, in fact, the meteorologist is standing in front of a large blue screen and the map is on a standard video monitor.
Each type of texture may be either bit-mapped or procedural. Bit-mapped textures store the value of each pixel of a given tile. Bit-mapped textures thus require an amount of storage that increases each time additional pixels are added. By contrast, procedural textures define pixel values according to a formula, which may include a random element.
Bitmaps are useful when a formula defining pixel values is unknown or does not exist. For example, a texture representing the Mona Lisa would be bit-mapped. Bitmaps may also be used when the time needed to calculate pixel values with a formula is too great. Procedural textures are sometimes preferred because they require less space than bitmaps. Bump maps are often procedural, using formulas to define distortions that resemble three-dimensional textures such as cloth or leather. The storage required by a procedural texture is generally independent of the number of pixels defined, since a formula is used rather than individual pixel values.
It is often desirable to rotate a texture. For instance, a textured region may be rotated by a graphic designer or by an animator. Unfortunately, conventional methods for rotating textures have serious drawbacks.
Some approaches fail completely to rotate textures. One such approach simply prevents all rotations. Another approach, illustrated in FIGS. 1 and 2, only rotates the border of a region, without any corresponding rotation of the enclosed texture. FIG. 1 shows a region enclosing a brick texture; FIG. 2 shows the same region after the border alone has been rotated.
Failure to rotate the texture and the border together leads to unrealistic images. For example, suppose an animation displays a cart carrying a load of bricks, with the load defined as a region containing a brick-pattern texture. As the cart begins climbing a hill, the outline of the bricks will rotate but the lines depicting individual bricks will not. This approach is relatively easy to implement, but often unsatisfactory. Viewers expect entire objects to rotate, not just their borders. Nonetheless, this method is used by drawing routines in currently popular computer programs.
A slightly better method is shown in FIGS. 3, 4, and 5. This approach rotates the texture by building and rotating a texture rectangle large enough to cover the entire rotated region. For clarity of illustration, a visual checkerboard texture is used, but the methods described also apply to other textures. First, the size of an unrotated region border 300 is measured in the X and Y directions, as shown in FIG. 3. Then a small texture tile (containing a texture that has not been rotated) is used to create a texture rectangle 302 large enough to cover the rotated region after the rectangle 302 is itself rotated.
As shown in FIG. 4, the region border 300 is rotated to obtain a rotated border 400. In addition, the entire texture rectangle 302 is rotated to produce a rotated rectangle 402. Rotation of the entire texture rectangle 302 to obtain the rectangle 402 may include significant computational effort. Finally, the rotated texture rectangle 402 is clipped. That is, portions of the rectangle 402 outside the rotated border 400 are discarded, producing the result shown in FIG. 5. This approach succeeds in seamlessly texturing an arbitrarily-sized rotated region only at the cost of creating, and then rotating, each and every pixel in the oversize rotated textured region, including many pixels that are clipped off and thus never really needed.
Another method is shown in FIGS. 6 through 9. This approach rotates a relatively small original texture tile 600 to produce a rotated tile 700 and then cuts an even smaller subtile 800 out of the rotated tile 700. The subtile 800 has vertically and horizontally aligned borders to facilitate stamping, clipping, and other computer graphics operations. Copies of the rotated subtile 800 are used to fill a rotated region border 902. A benefit of this approach is that many fewer computations are needed to rotate the texture, and fewer pixels are typically discarded when the texture is clipped to lie within the rotated border.
Unfortunately, a subtile cut in this way from within the rotated texture tile will often not seamlessly tile a region. That is, the tile boundaries will be apparent (as shown at 904 in FIG. 9) because pixel values do not vary across the border between two copies of the rotated subtile 800 in the same way that pixel values vary across the border of adjacent copies of the original unrotated tile 600.
Thus, it would be an improvement in the art to provide a method which, given a texture tile and a region defined by a border, produces a relatively small tile that contains the rotated texture and will seamlessly tile the region.
It would be a further advance if the method were useful with both bit-mapped and procedural textures, and with different varieties of texture such as visual textures, bump maps, and masks.
Such a method and system for texture rotation and seamless tiling are disclosed and claimed herein.